import { request } from '@/utils/request'
import type { 
  ExpressPickupRequest, 
  ExpressPickupResponse,
  AddressListResponse,
  CreateAddressRequest,
  CreateAddressResponse
} from '@/types/api/express-pickup'

// 创建快递代取订单
export const createExpressPickupOrder = (data: ExpressPickupRequest): Promise<ExpressPickupResponse> => {
  return request({
    url: '/express-pickup/create',
    method: 'POST',
    data
  })
}

// 获取地址列表
export const getAddressList = (): Promise<AddressListResponse> => {
  return request({
    url: '/address/list',
    method: 'GET'
  })
}

// 创建新地址
export const createAddress = (data: CreateAddressRequest): Promise<CreateAddressResponse> => {
  return request({
    url: '/address/create',
    method: 'POST',
    data
  })
}

// 更新地址
export const updateAddress = (id: string, data: Partial<CreateAddressRequest>): Promise<CreateAddressResponse> => {
  return request({
    url: `/address/update/${id}`,
    method: 'PUT',
    data
  })
}

// 删除地址
export const deleteAddress = (id: string): Promise<{ success: boolean; message: string }> => {
  return request({
    url: `/address/delete/${id}`,
    method: 'DELETE'
  })
}

// 设置默认地址
export const setDefaultAddress = (id: string): Promise<{ success: boolean; message: string }> => {
  return request({
    url: `/address/set-default/${id}`,
    method: 'PUT'
  })
}
